<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE>
<html>
<%@include file="/WEB-INF/view/base/common.jsp"%>
<head>
<title>登录</title>
<script type="text/javascript">
	$(document).keyup(function(e) {
		var theEvent = e || window.event;
		var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
		if (code == 13) {
			$("#login_btn").trigger("click");
		}
	});
</script>
</head>

<body>
<div class="bg_admin_log">
	<div style="padding-top:200px;">
    	<div class="admin_log">
        	<h3 class="logo"></h3>
            <ul id="inputul">
            	<li><input id="userName" name="userName" class="input" type="text" placeholder="请输入您的用户名" maxlength="20"/><span class="user_icon"></span></li>
	            <li><input id="password" class="input" type="password" autocomplete="off" placeholder="请输入您的密码" maxlength="32"/><span class="pwd_icon"></span></li>
	                <li style="display:none"><input id="password" name="password" autocomplete="off" class="input" type="password" placeholder="请输入您的密码" maxlength="32"/><span class="pwd_icon"></span></li>
                 <li><a class="btn_login" id="login_btn"  onclick="login_submit();">登  录</a><span id="pwdMsg"></span></li> 
            </ul>
        </div>
    </div>
</div>	
</body>
</html>
<script type="text/javascript">
 
function login_submit(){
	var userName = document.getElementById("userName").value;
    var password = document.getElementById("password").value;
    if(userName == ""){
    	layer.alert("用户名不能为空");
    	return false;
    }
   
    else{
    	if(password == ""){
    		layer.alert("密码不能为空");
	    	return false;
    	}else{
	   		 $.ajax({
	        	url: '${root }/'+ 'login.do',

	       		type:'post',
	        
	       		data:{"userName":userName,"password":$.md5(password)},

		        success: function(data){
		        	if(data == 100){
		        	 	location.href = '${root }/'+'admin/index.do'; 
		        	}else if(data == 101){
		        		layer.alert("用户账号或密码错误");
		        	}else if(data == 184){
		        		layer.alert("当前用户已经被禁用");
		        	}else if(data == 185 || data == 186){
		        		layer.alert("对不起，该用户角色不存在或已被禁用，请联系管理员");
		        	}else{
		        		layer.alert("登录异常，请重新登录");
		        	}
		         }
  			  });
    	}
    }
	
}
</script> 
